<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 
    <script>

        class Animal {
            constructor(name, speed) {
                this.name = name
                this.speed = 0
            }
            run(speed) {
                this.speed = speed
                console.log(`${this.name}以${this.speed}米/秒的速度奔跑`);
            }
            stop() {
                this.speed = 0
                console.log(`${this.name}停止了`);
            }
        }
        class Rabbit extends Animal {
            stop() {
                super.stop()
                console.log(`${this.name}很害怕，停了下来`);
            }
            hide() {
                this.stop()
                console.log(`${this.name}藏起来了`);
            }
        }
        const a = new Animal('未知生物')
        a.run(100)
        a.stop()
        const r = new Rabbit('🐇')
        r.run(200)
        r.stop()
        r.hide()
        console.log(a instanceof Animal);//true
        console.log(r instanceof Rabbit);//true
        console.log(r instanceof Animal);//true
        console.log(a instanceof Rabbit);//false

    </script>

    <script>

        //es5实现方法
        // function MyArray() {
        //     Array.apply(this, arguments)
        // }
        // MyArray.prototype = Object.create(Array.prototype)
        // MyArray.prototype.constructor = MyArray

        // const arr = new MyArray()
        // arr.push(1)
        // console.log(arr);

        //es6实现方法
        class MyArray extends Array { }
        const arr = new MyArray()
        arr.push(1)
        console.log(arr);
    </script> -->
    <div id="vs"></div>


    <script src="./练习.js"></script>
    <script>
        const vs = document.querySelector('#vs')
        const h1 = Hero.createHero(
            '绿巨人', 2000, 350, 300, 0.03, 0.02
        )
        const h2 = Hero.createHero(
            '蓝巨人', 1500, 250, 100, 0.05, 0.04
        )

        h1 = new Hero(h2)
        h2 = new Hero(h1)
    </script>
</body>

</html>